#!/bin/sh
#
# @license   http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author    Ian Moore <imooreyahoo@gmail.com>
# @copyright Copyright (c) 2011 Ian Moore
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.


set -e

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions

OMV_POSTFIX_CONFIG=${OMV_POSTFIX_CONFIG:-"/etc/postfix/main.cf"}

# Create '/etc/postfix/main.cf' configuration file
cat <<EOF >${OMV_POSTFIX_CONFIG}
mydestination = \$myhostname, localhost.\$mydomain, localhost
relayhost =
mynetworks = 127.0.0.1/32
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
default_transport = error
relay_transport = error
inet_protocols = ipv4
EOF

omv_config_update "//system/email/enable" "1"
omv_config_update "//system/email/primaryemail" "root@localhost"
omv_config_update "//system/email/secondaryemail" ""
omv_config_update "//system/email/sender" "root@localhost"

update-rc.d postfix defaults
